package chapter9;

import java.math.BigDecimal;

/**
 * 重写BigDecimalDemo的div方法
 */
public class Test9_6_3 {
    public static void main(String[] args) {
        System.out.println(div(-7.5,8.9,5));

    }

    public static BigDecimal div(double val1, double val2,int b){
        if(val2 == 0){
            System.out.println("被除数不能为0");
        }
        BigDecimal v1 = new BigDecimal(Double.toString(val1));
        BigDecimal v2 = new BigDecimal(Double.toString(val2));
        return v1.divide(v2,b,BigDecimal.ROUND_HALF_UP);
    }
}
